//
//  UUProductManager.h
//  UUCharterSupplier
//
//  Created by ZhangAo on 03/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import <UUFoundation/DKBaseManager.h>
#import "UUProductModel.h"
#import "UUProductPackageModel.h"
#import "UUProductConstants.h"

@protocol UUProductManagerObserver

@optional

- (void)productManagerDidUpdateProducts:(NSArray<NSNumber *> *)products;

- (void)productManagerDidRemoveProducts:(NSArray<NSNumber *> *)products;

- (void)productManagerDidUpdatePackages;

- (void)productManagerDidRemovePackages:(NSArray<NSNumber *> *)packages;

@end

#define GetProductManager()     ([UUProductManager sharedInstance])

@interface UUProductManager : DKBaseManager

// 更新产品
- (void)asyncUpdateProducts;

// 更新套餐
- (void)asyncUpdateProductPackages;

/**
 获取产品列表

 @param reviewStatus 审核状态
 @param onlineStatus 上架状态
 @param carCategoryId 车辆类型
 @return 符合条件的产品列表
 */
- (NSArray<NSNumber *> *)fetchProductsWithReviewStatus:(NSArray<NSNumber *> *)reviewStatus
                                          onlineStatus:(NSArray<NSNumber *> *)onlineStatus
                                         carCategoryId:(NSNumber *)carCategoryId;

// 获取产品 Model
- (UUProductModel *)fetchProductModelWithProductId:(NSNumber *)productId;

// 更新或添加产品，productId 为 nil 表示添加
- (void)asyncUpdateProductWithProductId:(NSNumber *)productId
                          carCategoryId:(NSNumber *)carCategoryId
                                fleetId:(NSNumber *)fleetId
                                   spec:(NSArray<UUProductSpecModel *> *)spec
                          completeBlock:(void (^)(NSError *error))completeBlock;

// 删除产品
- (void)asyncDeleteProductWithProductId:(NSNumber *)productId completeBlock:(void (^)(NSError *error))completeBlock;

// 获取产品套餐列表
- (NSArray<id> *)fetchProductPackagesWithPackageType:(UUProductPackageType)packageType;

// 获取产品套餐
- (UUProductPackageModel *)fetchProductPackageModelWithPackageId:(NSNumber *)packageId;

// 更新或添加产品套餐，packageId 为 nil 表示添加
- (void)asyncUpdatePackageWithPackageId:(NSNumber *)packageId
                            packageType:(UUProductPackageType)packageType
                                   name:(NSString *)name
                                   desc:(NSString *)desc
                                minTime:(NSString *)minTime
                                maxTime:(NSString *)maxTime
                              isHalfDay:(BOOL)isHalfDay
                               allDayKm:(NSInteger)allDayKm
                             allDayHour:(NSInteger)allDayHour
                              halfDayKm:(NSInteger)halfDayKm
                            halfDayHour:(NSInteger)halfDayHour
                          completeBlock:(void (^)(NSError *error))completeBlock;

// 删除产品套餐
- (void)asyncDeletePackageWithPackageId:(NSNumber *)packageId completeBlock:(void (^)(NSError *error))completeBlock;

// 申请下架
- (void)asyncApplicationToOfflineWithProductId:(NSNumber *)productId completeBlock:(void (^)(NSError *error))completeBlock;

// 取消申请下架
- (void)asyncCancelApplicationToOfflineWithProductId:(NSNumber *)productId completeBlock:(void (^)(NSError *error))completeBlock;

@end
